﻿namespace NMortgage.UI.Tests
{
    using System;

    using FluentValidation.TestHelper;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using NMortgage.UI.Model;

    [TestClass]
    public class BetaValidatorTest
    {
        #region Properties

        private BetaDistributionValidator Subject
        {
            get;
            set;
        }

        #endregion Properties

        #region Methods

        [TestMethod]
        public void BetaDistributionValidatorConstructorTest()
        {
            BetaDistributionValidator target = new BetaDistributionValidator();
            Assert.IsNotNull(target);
        }

        [TestMethod]
        public void Should_have_error_for_any_property_0_or_less()
        {
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Minimum, 0d);
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Alpha, 0d);
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Beta, 0d);
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Minimum, -1d);
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Alpha, -1d);
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Beta, -1d);
        }

        [TestMethod]
        public void Should_have_error_for_max_30_and_greater()
        {
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Maximum, 30d);
            Subject.ShouldHaveValidationErrorFor(distribution => distribution.Maximum, 30.01d);
        }

        [TestMethod]
        public void Should_not_have_error_for_Max_29_999()
        {
            Subject.ShouldNotHaveValidationErrorFor(distribution => distribution.Maximum, 29.999d);
        }

        [TestMethod]
        public void Should_not_have_error_for_Min_0_1()
        {
            Subject.ShouldNotHaveValidationErrorFor(distribution => distribution.Minimum, 0.1d);
        }

        [TestInitialize]
        public void TestInitialize()
        {
            Subject = new BetaDistributionValidator();
        }

        #endregion Methods
    }
}